-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new index to postgres datastore for GC #1550
Conversation
9fe5986
to
84250fd
Compare
@vroldanbet I wonder if we should have a migration to run |
@josephschorr from this post:
This other post suggests that analyze would be necessary if index has an expression to it, which is the case here:
My concerns here are:
|
84250fd
to
b3b5531
Compare
b3b5531
to
13f6d3f
Compare
Unlikely, but I believe the migration will wait for the index to complete (concurrently) before the next one is run, so the ANALYZE should apply afterwards
Yes, but one would imagine that CREATE INDEX is not also running unless someone is running the migration command twice (at the same time) |
13f6d3f
to
9025669
Compare
This blog post suggests running analyze should only be done when bulk loading, and that doing it in other situations is adding unnecessary pressure to the database:
Another post indicates that doing it after adding an index is actually a good idea:
I also tried to find evidences of whether
This post suggests it does not block
This other blog post also supports this idea:
And FWIW, anecdotal evidence on a cluster with millions of rows show the index being picked immediately after run with |
the original GC index was rarely selected when GC'ing relations with millions of relationships. This caused a sequential scan that could load potentially Gigabytes worth of data, and overload the database.⚠️ Postgres 13 and 14 do not correctly select this new index because the query planner struggles with the xid8 datatype. Postgres 15 will be needed for this index to actually work. For scenarios where relations aren't very wide, older PG versions may have an acceptable query latency for GC, but we strongly recommend moving to PG15. This migration also deletes the old suboptimal index after the new one is created.
9025669
to
1e81e68
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This adds 1 new indexes to optimize:
xid8
typeadd tuned GC index
the original GC index was rarely selected
when GC'ing relations with millions of relationships.
This caused a sequential scan that could load potentially
Gigabytes worth of data, and overload the database.
because the query planner struggles with the xid8 datatype.
Postgres 15 will be needed for this index to
actually work. For scenarios where relations aren't very wide,
older PG versions may have an acceptable query latency for GC,
but we strongly recommend moving to PG15.
This migration also deletes the old suboptimal index after
the new one is created.